/**
 * com.cnhis.his.customer.service.Aab1Service.java
 */
package com.mbmed.doctor.medadvice.service;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mbmed.doctor.medadvice.bo.Aab1Bo;
import com.mbmed.doctor.medadvice.mapper.Aab1;

/**
 * @file  Aab1Service.java
 * @author 刘武
 * @version 0.1
 * @todo	Aab1服务操作接口
 * Copyright(C), 2013-2014
 *		 Shenzhen Coordinates Software Development Co., Ltd.
 * History
 *   	1. Date: 2014-11-03 05:26:46
 *      	Author: 刘武
 *      	Modification: this file was created
 *   	2. ...
 */
@Path("/aab1")
@Component
public class Aab1Service {
	
	private static Logger logger = Logger.getLogger(Aab1.class);
	
	@Autowired
	private Aab1Bo aab1Bo;
	
	@Context
	Request request;

	
	/**
	 * 查找所有数据库记录
     * @return type : List 返回查询操作所有符合条件的记录的VO对象集合，操作失败返回null
     */
	@GET
	@Produces({MediaType.APPLICATION_JSON})
    public List<Aab1> getAll() throws Exception{
        List<Aab1> list = new ArrayList<Aab1>();
        return aab1Bo.getAll();        
    }
	
    /**
     * 查找符合条件的所有数据库记录
     * @param id 与数据库中主键对应的值
     * @return type :  返回查询操作所有符合条件的记录的VO对象，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("{id}")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public Aab1 getAab1(@PathParam("id") String id) throws Exception{
    	Aab1 aab1 = null;
    	return aab1Bo.get(id);        
    }
    /**
     * 向数据库中插入一条记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : 返回插入操作是否成功
     * @throws Exception
     */
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	public Aab1 saveAab1(
			@FormParam("aab01") java.lang.String aab01,
			@FormParam("aab02") java.lang.String aab02,
			@FormParam("aab03") java.lang.String aab03,
			@Context HttpServletResponse servletResponse
	) throws Exception {
		Aab1 aab1 = new Aab1();
		aab1.setAab01(aab01);
		aab1.setAab02(aab02);
		aab1.setAab03(aab03);

		return aab1 = aab1Bo.save(aab1);

	}
	/**
     * 删除数据库中与传入的值对象对应的记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : boolean 返回删除操作是否成功
     * @throws Exception
     */
	@DELETE
	@Path("{id}")
	public boolean removeAab1(@PathParam("id") String id) throws Exception{
		if(id == null) return false;
    	return aab1Bo.remove(id);

	}
	
}
